package com.traveldream.entities;

import java.io.Serializable;
import javax.persistence.*;
import java.util.Date;


/**
 * The persistent class for the excursion database table.
 * 
 */
@Entity
@NamedQueries({
	@NamedQuery(name="Excursion.findAll", query="SELECT e FROM Excursion e"),
	@NamedQuery(name="Excursion.findByPlace",query="SELECT e FROM Excursion e WHERE e.product.place.name LIKE :placeName"),
	@NamedQuery(name="Excursion.findBeetwenDates",query="SELECT e FROM Excursion e WHERE (e.date > :start AND e.date < :end)"),
	@NamedQuery(name="Excursion.findByStartingDate",query="SELECT e FROM Excursion e WHERE e.date > :start"),
	@NamedQuery(name="Excursion.findByEndingDate",query="SELECT e FROM Excursion e WHERE e.date < :end"),
	@NamedQuery(name="Excursion.findBeetwenDatesByPlace",query="SELECT e FROM Excursion e WHERE (e.date > :start AND e.date < :end) AND e.product.place.name LIKE :placeName")
})

public class Excursion implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name="product_id",insertable=false,updatable=false)
	private int productId;

	@Temporal(TemporalType.DATE)
	private Date date;

	private String description;

	private int duration;

	private String name;

	//bi-directional one-to-one association to Product
	@OneToOne
	private Product product;

	public Excursion() {
	}

	public int getProductId() {
		return this.productId;
	}

	public void setProductId(int productId) {
		this.productId = productId;
	}

	public Date getDate() {
		return this.date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public int getDuration() {
		return this.duration;
	}

	public void setDuration(int duration) {
		this.duration = duration;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Product getProduct() {
		return this.product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}
	
	@Override
	public boolean equals(Object obj) {
	    if(this.productId == ((Excursion) obj).productId) {
	        return true;
	    }else {
	        return false;
	    }
	}

}